﻿//------------------------------------------------------------------------------
// ╭─────────────────────────────╮
// │ ╭─╮     ╭─╮              TM │   ╠═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╣
// │ │ │     │ │                 │                                           ☺  
// │ │ ╰───╮ │ │ ╭─────╮ ╭─────╮ │     Name:Wedn.Net UrlHelper拓展方法类 ♮ ♪ ♩
// │ │ ╭─╮ │ │ │ │ ╭─╮ │ │ ╭─╮ │ │                                    ♫ ♭      
// │ │ ╰─╯ │ │ │ │ ╰─╯ │ │ ╰─╯ │ │     Author:iceStone               ♬ ♪       
// │ └─────╯ └─╯ ╰─────╯ ╰───╮ │ │     Chinese:汪磊                              
// │                     ┌───╯ │ │                                              
// │                     ╰─────╯ │   ╠═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╣
// ╰─────────────────────────────╯                                              
//------------------------------------------------------------------------------

using System;
using System.Web.Mvc;
using Wedn.Net.Common;

namespace Wedn.Net.Extensions
{
    /// <summary>
    /// UrlHelper拓展方法类
    /// </summary>
    public static class Url
    {
        #region OLD
        ///// <summary>
        ///// 获取样式表链接URL
        ///// </summary>
        ///// <param name="dir">目录</param>
        ///// <param name="load">加载样式表</param>
        ///// <param name="version">版本</param>
        ///// <returns>样式表链接URL</returns>
        //public static string StylesLink(string dir, string load, string version)
        //{
        //    return string.Format("{0}handlers/loadstyles.ashx?dir={1}&load={2}&ver={3}", Common.Config.SiteUrl, dir, load, version);
        //}

        ///// <summary>
        ///// 获取脚本链接URL
        ///// </summary>
        ///// <param name="dir">目录</param>
        ///// <param name="load">加载脚本</param>
        ///// <param name="version">版本</param>
        ///// <returns>脚本链接URL</returns>
        //public static string ScriptsLink(string dir, string load, string version)
        //{
        //    return string.Format("{0}handlers/loadscripts.ashx?dir={1}&load={2}&ver={3}", Common.Config.SiteUrl, dir, load, version);
        //} 
        #endregion

        #region 获取固定连接 +static string Permalink(this UrlHelper url, string link)
        /// <summary>
        /// 获取固定连接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="link">相对链接</param>
        /// <returns></returns>
        public static string Permalink(this UrlHelper url, string link)
        {
            if (link.IndexOf("://", StringComparison.Ordinal) == -1)
                link = Config.SiteUrl + link.TrimStart('/');
            return link;
        } 
        #endregion

        #region 文章页固定链接 +static string Post(this UrlHelper url, string item)
        /// <summary>
        /// 文章页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="slug">文章项</param>
        /// <returns>文章页链接</returns>
        public static string Post(this UrlHelper url, string slug)
        {
            return url.Action("Detail", "Blog", new { item = slug });
        }
        #endregion

        #region 类别页固定链接 +static string Category(this UrlHelper url, string item)
        /// <summary>
        /// 类别页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="slug">类别项</param>
        /// <returns>类别页链接</returns>
        public static string Category(this UrlHelper url, string slug)
        {
            return url.Action("Category", "Blog", new { item = slug });
        }
        #endregion

        #region 标签页固定链接 +static string Tag(this UrlHelper url, string item)
        /// <summary>
        /// 标签页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="slug">标签项</param>
        /// <returns>标签页链接</returns>
        public static string Tag(this UrlHelper url, string slug)
        {
            return url.Action("Tag", "Blog", new { item = slug });
        }
        #endregion

        #region 作者页固定链接 +static string Author(this UrlHelper url, string item)
        /// <summary>
        /// 作者页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="login">作者项</param>
        /// <returns>作者页链接</returns>
        public static string Author(this UrlHelper url, string login)
        {
            return url.Action("Author", "Blog", new { item = login });
        }
        #endregion

        #region 文章详细页固定链接 +static string Detail(this UrlHelper url, string item)
        /// <summary>
        /// 文章详细页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="item">文章项</param>
        /// <returns>文章详细页链接</returns>
        public static string Detail(this UrlHelper url, string item)
        {
            return url.Action("Detail", "Blog", new { item });
        }
        #endregion

        #region 页面详细页固定链接 +static string Page(this UrlHelper url, string item)
        /// <summary>
        /// 页面详细页固定链接
        /// </summary>
        /// <param name="url">UrlHelper</param>
        /// <param name="item">页面项</param>
        /// <returns>页面详细页链接</returns>
        public static string Page(this UrlHelper url, string item)
        {
            return url.Action("Page", "Blog", new { item });
        }
        #endregion
    }
}
